<div id="content-container" class="container">
    <div class="text-center">

    </div>
    <div class="user-section login-section" style="margin-top:20px;">
        <div class="logon-tab clearfix">
            <a href="javascript:" data-type="bind" class="active">{if $admin == '1'}绑定老师{else}绑定用户{/if}：</a>
        </div>
        <div class="bind-main login-main">
            <form name="form" id="bind-form" class="form-vertical" method="POST" action="{if $admin == '1'}{:url('user/admin')}{else}{:url('user/login')}{/if}">
                {:token()}
                <input type="hidden" name="platform" value="{$platform}"/>
                <input type="hidden" name="url" value="{$url}"/>
                <div class="form-group">
                    <label class="control-label">{if $admin == '1'}用户名{else}姓名{/if}:</label>
                    <div class="controls">
                        <input type="text" id="nickname" name="nickname" data-rule="required"
                               class="form-control input-lg" placeholder="{if $admin == '1'}请输入用户名{else}请输入姓名{/if}">
                        <p class="help-block"></p>
                    </div>
                </div>
                <div class="form-group">
                    <label class="control-label">{if $admin == '1'}密码{else}手机号{/if}：</label>
                    <div class="controls">
                        <input type="{if $admin == '1'}password{else}int{/if}" id="mobile" name="mobile" data-rule="required" class="form-control input-lg"
                               placeholder="{if $admin == '1'}请输入密码{else}请输入手机号{/if}">
                        <p class="help-block"></p>
                    </div>
                </div>
                <div class="form-group">
                    <button type="submit" class="btn btn-primary btn-block btn-lg">{:__('确认绑定')}</button>
                </div>
            </form>
        </div>
    </div>
</div>

<script>
    require.callback = function () {
        define('frontend/third', ['jquery', 'bootstrap', 'frontend', 'template', 'form'], function ($, undefined, Frontend, Template, Form) {
            var Controller = {
                prepare: function () {
                    var validatoroptions = {
                        invalid: function (form, errors) {
                            $.each(errors, function (i, j) {
                                Layer.msg(j);
                            });
                        }
                    };

                    $(".user-section .logon-tab > a").on("click", function () {
                        $(".bind-main,.register-main").addClass("hidden");
                        $("." + $(this).data("type") + "-main").removeClass("hidden");
                        $(".user-section .logon-tab > a").removeClass("active");
                        $(this).addClass("active");
                    });

                    //本地验证未通过时提示
                    $("#register-form").data("validator-options", validatoroptions);

                    //为表单绑定事件
                    Form.api.bindevent($("#bind-form"), function (data, ret) {
                        location.href = "{$bindurl}";
                        return false;
                    });

                    //为表单绑定事件
                    Form.api.bindevent($("#register-form"), function (data, ret) {
                        location.href = "{$bindurl}";
                        return false;
                    }, function (data) {
                        $("input[name=captcha]").next(".input-group-addon").find("img").trigger("click");
                    });
                }
            };
            return Controller;
        });
    }
</script>